package com.qhhc.config;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class OSSConfig {

    @Value("${aliyun.oss.endpoint:oss-cn-qingdao.aliyuncs.com}")
    private String endpoint;

    @Value("${aliyun.oss.accessKeyId:#{environment.ALIYUN_ACCESS_KEY_ID}}")
    private String accessKeyId;

    @Value("${aliyun.oss.accessKeySecret:#{environment.ALIYUN_ACCESS_KEY_SECRET}}")
    private String accessKeySecret;

    @Value("${aliyun.oss.bucketName:web-luomei}")
    private String bucketName;

    @Bean
    public OSS ossClient() {
        return new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
    }

    public String getBucketName() {
        return bucketName;
    }

    public String getEndpoint() {
        return endpoint;
    }
}